﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.Client;
using System.Diagnostics;
namespace YakShaver.CodePlex
{
    [Serializable()]
    public class CodePlexCredentialsProvider : ICredentialsProvider
    {
        #region ICredentialsProvider Members

        public System.Net.ICredentials GetCredentials(Uri uri, System.Net.ICredentials failedCredentials)
        {
            
            Debug.WriteLine("Get Credetnials URI: " + uri.ToString());
            Debug.WriteLine("Failed Credentials: " + failedCredentials.ToString());

            CodePlexProjectInfoSvc.ProjectInfoServiceSoapClient infoService = new YakShaver.CodePlex.CodePlexProjectInfoSvc.ProjectInfoServiceSoapClient();
            string username = infoService.CodePlexUserNameToTfsUserName("cege7480");

            System.Net.NetworkCredential nCredential = 
                new System.Net.NetworkCredential(username, "tyg1tnuy!!");
            return nCredential;

        }

        public void NotifyCredentialsAuthenticated(Uri uri)
        {
            Debug.WriteLine("NotifyCredentialsAuthenticated Uri: " + uri.ToString());
        }

        #endregion
    }
}
